# -*- coding: utf-8 -*-
from config import Configurator
import util
import error
from middleware.xslt import XsltProxy
from middleware.former import Former
from middleware.styler import Styler
from middleware.combiner import Combiner

def basic_stack(application, config, **kwargs):
	app = XsltProxy(application)
	app = Configurator(app, config=config, **kwargs)
	#app = error.ExceptionCollector(app)
	return app

def main_stack(application):
		return Combiner(Styler(Former(application)))

class Renyare(object): pass

class RenyareSimple(Renyare):
	"""
	Loads user-defined application with middleware-stack and application defined by user
	"""
	def __init__(self, **kwargs):
		#Renyare.__init__(self, **kwargs)
		self.app = kwargs.get('application') or util.simple_app
		self.load_list = kwargs.get('load_list') or []

class RenyareLayers(Renyare):
	def __init__(self, **kwargs):
		Renyare.__init__(self, **kwargs)
#		import layers
#		self.app = layers.Layers
		self.load_list = [('layers', {})
				#(layers.Layers, {}),
				]


class RenyareTags(Renyare):
	def __init__(self, **kwargs):
		Renyare.__init__(self, **kwargs)
		self.app = util.simple_app
		self.load_list = []
#		import tababr.middleware as tababr
#		self.app = tababr.Tababr(util.simple_app)
#		self.load_list = [
#			('login', {}),
#			('former', {}),
#			('database', {}),
#			]
